(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

primessieve(from(s(s(0))))
from(X) → cons(X, n__from(n__s(X)))
head(cons(X, Y)) → X
tail(cons(X, Y)) → activate(Y)
if(true, X, Y) → activate(X)
if(false, X, Y) → activate(Y)
filter(s(s(X)), cons(Y, Z)) → if(divides(s(s(X)), Y), n__filter(n__s(n__s(X)), activate(Z)), n__cons(Y, n__filter(X, n__sieve(Y))))
sieve(cons(X, Y)) → cons(X, n__filter(X, n__sieve(activate(Y))))
from(X) → n__from(X)
s(X) → n__s(X)
filter(X1, X2) → n__filter(X1, X2)
cons(X1, X2) → n__cons(X1, X2)
sieve(X) → n__sieve(X)
activate(n__from(X)) → from(activate(X))
activate(n__s(X)) → s(activate(X))
activate(n__filter(X1, X2)) → filter(activate(X1), activate(X2))
activate(n__cons(X1, X2)) → cons(activate(X1), X2)
activate(n__sieve(X)) → sieve(activate(X))
activate(X) → X

Rewrite Strategy: INNERMOST

(1) DependencyGraphProof (BOTH BOUNDS(ID, ID) transformation)

The following rules are not reachable from basic terms in the dependency graph and can be removed:
head(cons(X, Y)) → X
tail(cons(X, Y)) → activate(Y)

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

primessieve(from(s(s(0))))
activate(n__filter(X1, X2)) → filter(activate(X1), activate(X2))
sieve(cons(X, Y)) → cons(X, n__filter(X, n__sieve(activate(Y))))
sieve(X) → n__sieve(X)
if(true, X, Y) → activate(X)
activate(X) → X
cons(X1, X2) → n__cons(X1, X2)
activate(n__s(X)) → s(activate(X))
filter(X1, X2) → n__filter(X1, X2)
activate(n__from(X)) → from(activate(X))
from(X) → cons(X, n__from(n__s(X)))
filter(s(s(X)), cons(Y, Z)) → if(divides(s(s(X)), Y), n__filter(n__s(n__s(X)), activate(Z)), n__cons(Y, n__filter(X, n__sieve(Y))))
if(false, X, Y) → activate(Y)
from(X) → n__from(X)
s(X) → n__s(X)
activate(n__cons(X1, X2)) → cons(activate(X1), X2)
activate(n__sieve(X)) → sieve(activate(X))

Rewrite Strategy: INNERMOST

(3) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(4) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

primessieve(from(s(s(0)))) [1]
activate(n__filter(X1, X2)) → filter(activate(X1), activate(X2)) [1]
sieve(cons(X, Y)) → cons(X, n__filter(X, n__sieve(activate(Y)))) [1]
sieve(X) → n__sieve(X) [1]
if(true, X, Y) → activate(X) [1]
activate(X) → X [1]
cons(X1, X2) → n__cons(X1, X2) [1]
activate(n__s(X)) → s(activate(X)) [1]
filter(X1, X2) → n__filter(X1, X2) [1]
activate(n__from(X)) → from(activate(X)) [1]
from(X) → cons(X, n__from(n__s(X))) [1]
filter(s(s(X)), cons(Y, Z)) → if(divides(s(s(X)), Y), n__filter(n__s(n__s(X)), activate(Z)), n__cons(Y, n__filter(X, n__sieve(Y)))) [1]
if(false, X, Y) → activate(Y) [1]
from(X) → n__from(X) [1]
s(X) → n__s(X) [1]
activate(n__cons(X1, X2)) → cons(activate(X1), X2) [1]
activate(n__sieve(X)) → sieve(activate(X)) [1]

Rewrite Strategy: INNERMOST

(5) InnermostUnusableRulesProof (BOTH BOUNDS(ID, ID) transformation)

Removed the following rules with non-basic left-hand side, as they cannot be used in innermost rewriting:

sieve(cons(X, Y)) → cons(X, n__filter(X, n__sieve(activate(Y)))) [1]
filter(s(s(X)), cons(Y, Z)) → if(divides(s(s(X)), Y), n__filter(n__s(n__s(X)), activate(Z)), n__cons(Y, n__filter(X, n__sieve(Y)))) [1]

Due to the following rules that have to be used instead:

cons(X1, X2) → n__cons(X1, X2) [1]
s(X) → n__s(X) [1]

(6) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

primessieve(from(s(s(0)))) [1]
activate(n__filter(X1, X2)) → filter(activate(X1), activate(X2)) [1]
sieve(X) → n__sieve(X) [1]
if(true, X, Y) → activate(X) [1]
activate(X) → X [1]
cons(X1, X2) → n__cons(X1, X2) [1]
activate(n__s(X)) → s(activate(X)) [1]
filter(X1, X2) → n__filter(X1, X2) [1]
activate(n__from(X)) → from(activate(X)) [1]
from(X) → cons(X, n__from(n__s(X))) [1]
if(false, X, Y) → activate(Y) [1]
from(X) → n__from(X) [1]
s(X) → n__s(X) [1]
activate(n__cons(X1, X2)) → cons(activate(X1), X2) [1]
activate(n__sieve(X)) → sieve(activate(X)) [1]

Rewrite Strategy: INNERMOST

(7) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(8) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

primessieve(from(s(s(0)))) [1]
activate(n__filter(X1, X2)) → filter(activate(X1), activate(X2)) [1]
sieve(X) → n__sieve(X) [1]
if(true, X, Y) → activate(X) [1]
activate(X) → X [1]
cons(X1, X2) → n__cons(X1, X2) [1]
activate(n__s(X)) → s(activate(X)) [1]
filter(X1, X2) → n__filter(X1, X2) [1]
activate(n__from(X)) → from(activate(X)) [1]
from(X) → cons(X, n__from(n__s(X))) [1]
if(false, X, Y) → activate(Y) [1]
from(X) → n__from(X) [1]
s(X) → n__s(X) [1]
activate(n__cons(X1, X2)) → cons(activate(X1), X2) [1]
activate(n__sieve(X)) → sieve(activate(X)) [1]

The TRS has the following type information:
primes :: 0:n__filter:n__sieve:n__cons:n__s:n__from
sieve :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
from :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
s :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
0 :: 0:n__filter:n__sieve:n__cons:n__s:n__from
activate :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
n__filter :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
filter :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
n__sieve :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
if :: true:false → 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
true :: true:false
cons :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
n__cons :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
n__s :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
n__from :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
false :: true:false

Rewrite Strategy: INNERMOST

(9) CompletionProof (UPPER BOUND(ID) transformation)

The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added:
none

And the following fresh constants: none

(10) Obligation:

Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

primessieve(from(s(s(0)))) [1]
activate(n__filter(X1, X2)) → filter(activate(X1), activate(X2)) [1]
sieve(X) → n__sieve(X) [1]
if(true, X, Y) → activate(X) [1]
activate(X) → X [1]
cons(X1, X2) → n__cons(X1, X2) [1]
activate(n__s(X)) → s(activate(X)) [1]
filter(X1, X2) → n__filter(X1, X2) [1]
activate(n__from(X)) → from(activate(X)) [1]
from(X) → cons(X, n__from(n__s(X))) [1]
if(false, X, Y) → activate(Y) [1]
from(X) → n__from(X) [1]
s(X) → n__s(X) [1]
activate(n__cons(X1, X2)) → cons(activate(X1), X2) [1]
activate(n__sieve(X)) → sieve(activate(X)) [1]

The TRS has the following type information:
primes :: 0:n__filter:n__sieve:n__cons:n__s:n__from
sieve :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
from :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
s :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
0 :: 0:n__filter:n__sieve:n__cons:n__s:n__from
activate :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
n__filter :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
filter :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
n__sieve :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
if :: true:false → 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
true :: true:false
cons :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
n__cons :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
n__s :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
n__from :: 0:n__filter:n__sieve:n__cons:n__s:n__from → 0:n__filter:n__sieve:n__cons:n__s:n__from
false :: true:false

Rewrite Strategy: INNERMOST

(11) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

0 => 0
true => 1
false => 0

(12) Obligation:

Complexity RNTS consisting of the following rules:

activate(z) -{ 1 }→ X :|: X >= 0, z = X
activate(z) -{ 1 }→ sieve(activate(X)) :|: z = 1 + X, X >= 0
activate(z) -{ 1 }→ s(activate(X)) :|: z = 1 + X, X >= 0
activate(z) -{ 1 }→ from(activate(X)) :|: z = 1 + X, X >= 0
activate(z) -{ 1 }→ filter(activate(X1), activate(X2)) :|: X1 >= 0, X2 >= 0, z = 1 + X1 + X2
activate(z) -{ 1 }→ cons(activate(X1), X2) :|: X1 >= 0, X2 >= 0, z = 1 + X1 + X2
cons(z, z') -{ 1 }→ 1 + X1 + X2 :|: X1 >= 0, X2 >= 0, z = X1, z' = X2
filter(z, z') -{ 1 }→ 1 + X1 + X2 :|: X1 >= 0, X2 >= 0, z = X1, z' = X2
from(z) -{ 1 }→ cons(X, 1 + (1 + X)) :|: X >= 0, z = X
from(z) -{ 1 }→ 1 + X :|: X >= 0, z = X
if(z, z', z'') -{ 1 }→ activate(X) :|: z' = X, Y >= 0, z = 1, z'' = Y, X >= 0
if(z, z', z'') -{ 1 }→ activate(Y) :|: z' = X, Y >= 0, z'' = Y, X >= 0, z = 0
primes -{ 1 }→ sieve(from(s(s(0)))) :|:
s(z) -{ 1 }→ 1 + X :|: X >= 0, z = X
sieve(z) -{ 1 }→ 1 + X :|: X >= 0, z = X

Only complete derivations are relevant for the runtime complexity.

(13) CompleteCoflocoProof (EQUIVALENT transformation)

Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo:

eq(start(V, V1, V2),0,[primes(Out)],[]).
eq(start(V, V1, V2),0,[activate(V, Out)],[V >= 0]).
eq(start(V, V1, V2),0,[sieve(V, Out)],[V >= 0]).
eq(start(V, V1, V2),0,[if(V, V1, V2, Out)],[V >= 0,V1 >= 0,V2 >= 0]).
eq(start(V, V1, V2),0,[cons(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(start(V, V1, V2),0,[filter(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(start(V, V1, V2),0,[from(V, Out)],[V >= 0]).
eq(start(V, V1, V2),0,[s(V, Out)],[V >= 0]).
eq(primes(Out),1,[s(0, Ret000),s(Ret000, Ret00),from(Ret00, Ret0),sieve(Ret0, Ret)],[Out = Ret]).
eq(activate(V, Out),1,[activate(X11, Ret01),activate(X21, Ret1),filter(Ret01, Ret1, Ret2)],[Out = Ret2,X11 >= 0,X21 >= 0,V = 1 + X11 + X21]).
eq(sieve(V, Out),1,[],[Out = 1 + X3,X3 >= 0,V = X3]).
eq(if(V, V1, V2, Out),1,[activate(X4, Ret3)],[Out = Ret3,V1 = X4,Y1 >= 0,V = 1,V2 = Y1,X4 >= 0]).
eq(activate(V, Out),1,[],[Out = X5,X5 >= 0,V = X5]).
eq(cons(V, V1, Out),1,[],[Out = 1 + X12 + X22,X12 >= 0,X22 >= 0,V = X12,V1 = X22]).
eq(activate(V, Out),1,[activate(X6, Ret02),s(Ret02, Ret4)],[Out = Ret4,V = 1 + X6,X6 >= 0]).
eq(filter(V, V1, Out),1,[],[Out = 1 + X13 + X23,X13 >= 0,X23 >= 0,V = X13,V1 = X23]).
eq(activate(V, Out),1,[activate(X7, Ret03),from(Ret03, Ret5)],[Out = Ret5,V = 1 + X7,X7 >= 0]).
eq(from(V, Out),1,[cons(X8, 1 + (1 + X8), Ret6)],[Out = Ret6,X8 >= 0,V = X8]).
eq(if(V, V1, V2, Out),1,[activate(Y2, Ret7)],[Out = Ret7,V1 = X9,Y2 >= 0,V2 = Y2,X9 >= 0,V = 0]).
eq(from(V, Out),1,[],[Out = 1 + X10,X10 >= 0,V = X10]).
eq(s(V, Out),1,[],[Out = 1 + X14,X14 >= 0,V = X14]).
eq(activate(V, Out),1,[activate(X15, Ret04),cons(Ret04, X24, Ret8)],[Out = Ret8,X15 >= 0,X24 >= 0,V = 1 + X15 + X24]).
eq(activate(V, Out),1,[activate(X16, Ret05),sieve(Ret05, Ret9)],[Out = Ret9,V = 1 + X16,X16 >= 0]).
input_output_vars(primes(Out),[],[Out]).
input_output_vars(activate(V,Out),[V],[Out]).
input_output_vars(sieve(V,Out),[V],[Out]).
input_output_vars(if(V,V1,V2,Out),[V,V1,V2],[Out]).
input_output_vars(cons(V,V1,Out),[V,V1],[Out]).
input_output_vars(filter(V,V1,Out),[V,V1],[Out]).
input_output_vars(from(V,Out),[V],[Out]).
input_output_vars(s(V,Out),[V],[Out]).

CoFloCo proof output:
Preprocessing Cost Relations
=====================================

#### Computed strongly connected components
0. non_recursive : [cons/3]
1. non_recursive : [filter/3]
2. non_recursive : [from/2]
3. non_recursive : [s/2]
4. non_recursive : [sieve/2]
5. recursive [non_tail,multiple] : [activate/2]
6. non_recursive : [if/4]
7. non_recursive : [primes/1]
8. non_recursive : [start/3]

#### Obtained direct recursion through partial evaluation
0. SCC is completely evaluated into other SCCs
1. SCC is completely evaluated into other SCCs
2. SCC is partially evaluated into from/2
3. SCC is completely evaluated into other SCCs
4. SCC is completely evaluated into other SCCs
5. SCC is partially evaluated into activate/2
6. SCC is partially evaluated into if/4
7. SCC is partially evaluated into primes/1
8. SCC is partially evaluated into start/3

Control-Flow Refinement of Cost Relations
=====================================

### Specialization of cost equations from/2
* CE 15 is refined into CE [16]
* CE 14 is refined into CE [17]


### Cost equations --> "Loop" of from/2
* CEs [16] --> Loop 11
* CEs [17] --> Loop 12

### Ranking functions of CR from(V,Out)

#### Partial ranking functions of CR from(V,Out)


### Specialization of cost equations activate/2
* CE 10 is refined into CE [18]
* CE 11 is refined into CE [19,20]
* CE 9 is refined into CE [21]
* CE 8 is refined into CE [22]


### Cost equations --> "Loop" of activate/2
* CEs [22] --> Loop 13
* CEs [21] --> Loop 14
* CEs [18,19] --> Loop 15
* CEs [20] --> Loop 16

### Ranking functions of CR activate(V,Out)
* RF of phase [13,15,16]: [V]

#### Partial ranking functions of CR activate(V,Out)
* Partial RF of phase [13,15,16]:
- RF of loop [13:1,13:2,15:1,16:1]:
V


### Specialization of cost equations if/4
* CE 12 is refined into CE [23,24]
* CE 13 is refined into CE [25,26]


### Cost equations --> "Loop" of if/4
* CEs [24] --> Loop 17
* CEs [23] --> Loop 18
* CEs [26] --> Loop 19
* CEs [25] --> Loop 20

### Ranking functions of CR if(V,V1,V2,Out)

#### Partial ranking functions of CR if(V,V1,V2,Out)


### Specialization of cost equations primes/1
* CE 7 is refined into CE [27,28]


### Cost equations --> "Loop" of primes/1
* CEs [28] --> Loop 21
* CEs [27] --> Loop 22

### Ranking functions of CR primes(Out)

#### Partial ranking functions of CR primes(Out)


### Specialization of cost equations start/3
* CE 2 is refined into CE [29,30]
* CE 3 is refined into CE [31,32]
* CE 4 is refined into CE [33]
* CE 5 is refined into CE [34,35,36,37]
* CE 6 is refined into CE [38,39]


### Cost equations --> "Loop" of start/3
* CEs [29,30,31,32,33,34,35,36,37,38,39] --> Loop 23

### Ranking functions of CR start(V,V1,V2)

#### Partial ranking functions of CR start(V,V1,V2)


Computing Bounds
=====================================

#### Cost of chains of from(V,Out):
* Chain [12]: 2
with precondition: [2*V+3=Out,V>=0]

* Chain [11]: 1
with precondition: [V+1=Out,V>=0]


#### Cost of chains of activate(V,Out):
* Chain [14]: 1
with precondition: [V=Out,V>=0]

* Chain [multiple([13,15,16],[[14]])]: 7*it(13)+1*it([14])+0
Such that:it([14]) =< V+1
aux(1) =< V
it(13) =< aux(1)

with precondition: [V>=1,Out>=V]


#### Cost of chains of if(V,V1,V2,Out):
* Chain [20]: 2
with precondition: [V=0,V2=Out,V1>=0,V2>=0]

* Chain [19]: 1*s(1)+7*s(3)+1
Such that:s(2) =< V2
s(1) =< V2+1
s(3) =< s(2)

with precondition: [V=0,V1>=0,V2>=1,Out>=V2]

* Chain [18]: 2
with precondition: [V=1,V1=Out,V1>=0,V2>=0]

* Chain [17]: 1*s(4)+7*s(6)+1
Such that:s(5) =< V1
s(4) =< V1+1
s(6) =< s(5)

with precondition: [V=1,V1>=1,V2>=0,Out>=V1]


#### Cost of chains of primes(Out):
* Chain [22]: 5
with precondition: [Out=4]

* Chain [21]: 6
with precondition: [Out=8]


#### Cost of chains of start(V,V1,V2):
* Chain [23]: 1*s(7)+7*s(9)+1*s(11)+7*s(12)+1*s(14)+7*s(15)+6
Such that:s(8) =< V
s(7) =< V+1
s(13) =< V1
s(14) =< V1+1
s(10) =< V2
s(11) =< V2+1
s(9) =< s(8)
s(15) =< s(13)
s(12) =< s(10)

with precondition: []


Closed-form bounds of start(V,V1,V2):
-------------------------------------
* Chain [23] with precondition: []
- Upper bound: nat(V)*7+6+nat(V1)*7+nat(V2)*7+nat(V+1)+nat(V1+1)+nat(V2+1)
- Complexity: n

### Maximum cost of start(V,V1,V2): nat(V)*7+6+nat(V1)*7+nat(V2)*7+nat(V+1)+nat(V1+1)+nat(V2+1)
Asymptotic class: n
* Total analysis performed in 176 ms.

(14) BOUNDS(1, n^1)